<template>
	<view>
		<!--service/setpage/setpage.wxml-->
		<view class="question">
			<scroll-view class="scroll-box" :scroll-y="true" :show-scrollbar="false" enhanced="true" @scrolltolower="more">
				<u-collapse :value="active" @change="onChange">
					<u-collapse-item v-for="(item,index) in list" :title="item.title" :name="item.id">
						{{ item.content }}
					</u-collapse-item>
				</u-collapse>
				<!-- <u-empty description="暂无内容" wx:if="{{finish && list.length === 0}}" /> -->
			</scroll-view>
		</view>
	</view>
</template>

<script>
import http from '../../utils/http';
export default {
	data() {
		return {
			list: [],
			finish: false,
			loading: false,
			page: 1,
			active: ''
		};
	},
	onLoad(options) {
		this.reload();
	},
	methods: {
		onChange(event) {
			this.active = event.detail
		},
		reload() {
			this.list = [],
			this.page = 1,
			this.finish = false
			this.getList();
		},
		more() {
			this.page = ++this.page
			this.getList();
		},
		getList() {
			if (this.finish) {
				return;
			}
			if (this.loading) {
				return;
			}
			this.loading = true
			http.get('index/help', {
				page: this.page
			})
				.then((res) => {
					if (res.data.length === 0) {
						this.finish = true
					}
					let arr = this.list.concat(res.data);
					this.list = arr
				})
				.finally((res) => {
					this.loading = false
				});
		}
	}
};
</script>

<style>
page {
	background-color: #fff;
}

.question {
	height: 100vh;
}
.scroll-box {
	height: 100%;
}
</style>
